package service

import (
	"TD-UI/internal/model"
	"context"
)

type (
	ITable interface {
		GetTable(ctx context.Context, req model.TableReq) (res model.TableRes, err error)
		GetTableData(ctx context.Context, req model.TableDataReq) (res model.TableDataRes, err error)
		GetTableColumns(ctx context.Context, req model.TableDataReq) (res model.TableDataRes, err error)
		QueryTableData(ctx context.Context, req model.TableDataQueryReq) (res model.TableDataRes, err error)
		DelTable(ctx context.Context, req model.TableDelReq) (res model.TableRes, err error)
		DdlTable(ctx context.Context, req model.TableDdlReq) (res model.TableRes, err error)
		CreateTable(ctx context.Context, req model.TableCreateReq) (res model.TableRes, err error)
		ExecSqlTableData(ctx context.Context, req model.TableExecSqlReq) (res model.TableRes, err error)
	}
)

var (
	localTable ITable
)

func Table() ITable {
	if localLink == nil {
		panic("implement not found for interface ITable, forgot register?")
	}
	return localTable
}

func RegisterTable(i ITable) {
	localTable = i
}
